package com.win.cn.core.pane;

import com.win.cn.core.model.TimeAndUTC;
import com.win.cn.core.model.WebRequst;
import com.win.cn.util.WeatherUtil;

import javafx.geometry.Insets;
import javafx.scene.control.TextArea;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;

/**
 * 创建右侧详细栏
 * @author wangzh
 * 2018年6月6日 上午11:16:16
 */
public class DetailPane {
	
	public AnchorPane createMainPane(){
		AnchorPane detailPane=new AnchorPane();
		detailPane.setPrefWidth(400.0);
		
		
		int left=255;
		detailPane.setBackground(new Background(new BackgroundFill(Color.rgb(left, left, left, .99),null,null)));
		return detailPane;
	}
	
	/**
	 * web请求
	 */
	
	public AnchorPane createWebRequest(){
	    
	    GridPane grid = new GridPane();
	    grid.setVgap(4);
	    grid.setHgap(10);
	    grid.setPadding(new Insets(15, 5, 5, 20));
	    
	    
	    Text text = new Text(10, 50, "");     
		text.prefWidth(400);         
		text.setFont(new Font(12));
		
		
		new WebRequst().doQuest(grid,text);
		
	    AnchorPane detailPane=createMainPane();
		detailPane.getChildren().addAll(grid,text);
		return detailPane;
	}
	
	/**
	 * 天气页
	 * @return
	 */
	public AnchorPane createWeatherPane(){
		Text text = new Text(10, 50, "This is a test");     
		text.prefWidth(400);     
		text.setText(WeatherUtil.getWeather("北京"));     
		text.setFont(new Font(12));
		
		AnchorPane detailPane=createMainPane();
		detailPane.getChildren().add(text);
		return detailPane;
	}
	
	/**
	 * 时间戳页面
	 */
	
	public AnchorPane createTimePane(){
	    
	    GridPane grid = new GridPane();
	    grid.setVgap(4);
	    grid.setHgap(10);
	    grid.setPadding(new Insets(15, 5, 5, 20));
	    
	    TimeAndUTC timeAndUTC=new TimeAndUTC();
	    timeAndUTC.utcTotime(grid);
	    timeAndUTC.timeToutc(grid);
	    
	    AnchorPane detailPane=createMainPane();
	   
		detailPane.getChildren().add(grid);
		return detailPane;
	}
	
	/**
	 * 比较
	 */
	public AnchorPane createSpace(){

		FlowPane grid = new FlowPane();
	    
	    TextArea leftText=new TextArea();
	    TextArea rightText=new TextArea();
	    grid.getChildren().addAll(leftText,rightText);
	    
	    
	    AnchorPane detailPane=createMainPane();
	   
		detailPane.getChildren().add(grid);
		return detailPane;
	}
	
}
